package cn.jhc;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/submit.do")
public class SubmitServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        String sex = req.getParameter("sex");
        String[] hobbiesArr = req.getParameterValues("hobbies");
        String hobbies = "";
        for (String string : hobbiesArr) {
            hobbies += string + ",";
        }
        System.out.println(name);
        System.out.println(sex);
        for (String string : hobbiesArr) {
            System.out.println(string);
        }
        // try {
        //     new DaoRu().save(name, sex, hobbies);
        // } catch (Exception e) {
        //    e.printStackTrace();
        //    resp.sendError(501);
        //    return;
        // }
        resp.sendRedirect("/list.html");
        //测试
    }
}
